Skip to content

net: skip IPv6 regex when the string has no colon - #66165

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
anonrig:cursor/net-hotpath-ead2
Sep 25, 2026
Merged

nodejs-github-bot merged 1 commit into
nodejs:mainfrom
anonrig:cursor/net-hotpath-ead2

Conversation

@anonrig

@anonrig anonrig commented Sep 21, 2026

Copy link
Copy Markdown
Member

net.isIPv6() always ran the large IPv6 regular expression, including for IPv4 addresses and hostnames. An IPv6 address always contains :, so reject those strings first.

Object / toString inputs still go through RegExp.prototype.test so existing coercion (covered by test-net-isip.js) is unchanged.

This change was implemented with assistance from a closed-source coding agent. I verified the source, official benchmark/net results, and test-net-isip.js / test-net-blocklist.js.

Official benches

Three-run medians, n=1e7:

bench main this PR delta
net/net-is-ip-v6.js 6.48M 8.23M +27%
net/net-is-ip-v4.js 12.31M 12.52M unchanged

Tests

test-net-isip.js, test-net-blocklist.js.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. net Issues and PRs related to the net subsystem. labels Sep 21, 2026
@anonrig
anonrig marked this pull request as ready for review September 21, 2026 04:07
IPv6 addresses always contain ':'. Reject IPv4 addresses and
hostnames before running the IPv6 regular expression.

Official benchmark/net/net-is-ip-v6.js is about 27% faster.
net-is-ip-v4.js is unchanged.

Assisted-by: a closed-source coding agent
Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com>
Co-authored-by: Yagiz Nizipli <anonrig@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/net-hotpath-ead2 branch from b4aacd6 to da12549 Compare September 21, 2026 04:32
@codecov

codecov Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.29%. Comparing base (dd5dfb5) to head (da12549).
⚠️ Report is 140 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66165      +/-   ##
==========================================
+ Coverage   90.27%   90.29%   +0.02%     
==========================================
  Files         790      790              
  Lines      271651   272049     +398     
  Branches    51842    51939      +97     
==========================================
+ Hits       245228   245658     +430     
+ Misses      16928    16889      -39     
- Partials     9495     9502       +7     
Files with missing lines Coverage Δ
lib/internal/net.js 100.00% <100.00%> (ø)

... and 57 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pimterry pimterry added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Sep 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Sep 21, 2026
@nodejs-github-bot

This comment has been minimized.

@panva panva added author ready PRs with CI started, the required approvals, and no outstanding review comments. resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. labels Sep 25, 2026
@github-actions github-actions Bot added resume-ci-failed Resuming CI with the resume-ci label failed and requires manual intervention. and removed resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. labels Sep 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Failed to resume CI

✖ Failed to resume PR CI: 404 Not Found

Full Auto Start CI output
�[36m⠋�[39m Validating Jenkins credentials
�[36m⠋�[39m Validating Jenkins credentials
✔  Jenkins credentials valid
�[36m⠙�[39m Looking for CI runs for pull request 66165
�[36m⠙�[39m Looking for CI runs for pull request 66165
�[36m⠙�[39m Getting PR from nodejs/node/pull/66165
�[36m⠙�[39m Getting reviews from nodejs/node/pull/66165
�[36m⠙�[39m Getting comments from nodejs/node/pull/66165
✔  Found PR CI job 77709
�[36m⠹�[39m Querying data for job/node-test-pull-request/77709/
�[36m⠹�[39m Querying data for job/node-test-pull-request/77709/
�[36m⠹�[39m Querying API for job/node-test-pull-request/77709/
✔  Build data downloaded
�[36m⠹�[39m Checking failures against changed PR files
�[36m⠹�[39m Checking failures against changed PR files
�[36m⠸�[39m Querying data for job/node-test-pull-request/77709/
�[36m⠸�[39m Querying API for job/node-test-pull-request/77709/
✔  Build data downloaded
�[36m⠼�[39m Querying failures of job/node-test-commit/92504/
�[36m⠼�[39m Querying failures of job/node-test-commit/92504/
�[36m⠼�[39m Querying API for job/node-test-commit-linux/73334/
�[36m⠼�[39m Querying API for job/node-test-commit-plinux/66480/
�[36m⠼�[39m Querying API for job/node-test-linter/67437/
�[36m⠼�[39m Querying API for job/node-test-commit-arm-debug/26050/
�[36m⠼�[39m Querying API for job/node-test-commit-windows-fanned/80582/
�[36m⠴�[39m Querying console text for job/node-test-commit-linux/73334/
�[36m⠦�[39m Querying API for job/node-test-commit-plinux/nodes=rhel8-ppc64le/66476/
�[36m⠦�[39m Querying console text for job/node-test-linter/67437/
�[36m⠦�[39m Querying console text for job/node-test-commit-arm-debug/26050/
�[36m⠦�[39m Querying API for job/node-compile-windows/69258/
�[36m⠧�[39m Querying API for job/node-compile-windows/nodes=win-vs2022/69223/
�[36m⠧�[39m Querying API for job/node-compile-windows/nodes=win-vs2022-x86/69223/
�[36m⠧�[39m Querying API for job/node-compile-windows/nodes=win-vs2022_clang/69258/
�[36m⠧�[39m Querying API for job/node-compile-windows/nodes=win-vs2022_clang-arm64/69258/
�[36m⠇�[39m Querying console text for job/node-compile-windows/nodes=win-vs2022_clang/69258/
�[36m⠇�[39m Querying console text for job/node-compile-windows/nodes=win-vs2022_clang-arm64/69258/
✔  Data downloaded
✔  No changed PR files found in available failure details
�[36m⠏�[39m Resuming PR CI job 77709
�[36m⠏�[39m Resuming PR CI job 77709
✖  Failed to resume PR CI: 404 Not Found

View workflow run

@panva panva removed the resume-ci-failed Resuming CI with the resume-ci label failed and requires manual intervention. label Sep 25, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@panva panva added the commit-queue PRs queued for automated landing through the Commit Queue. label Sep 25, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 0a36bce into nodejs:main Sep 25, 2026
80 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 0a36bce

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Sep 25, 2026
aduh95 pushed a commit that referenced this pull request Sep 27, 2026
IPv6 addresses always contain ':'. Reject IPv4 addresses and
hostnames before running the IPv6 regular expression.

Official benchmark/net/net-is-ip-v6.js is about 27% faster.
net-is-ip-v4.js is unchanged.

Assisted-by: a closed-source coding agent
Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com>
Co-authored-by: Yagiz Nizipli <anonrig@users.noreply.github.com>
PR-URL: #66165
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
HoonDongKang pushed a commit to HoonDongKang/node that referenced this pull request Sep 28, 2026
IPv6 addresses always contain ':'. Reject IPv4 addresses and
hostnames before running the IPv6 regular expression.

Official benchmark/net/net-is-ip-v6.js is about 27% faster.
net-is-ip-v4.js is unchanged.

Assisted-by: a closed-source coding agent
Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com>
Co-authored-by: Yagiz Nizipli <anonrig@users.noreply.github.com>
PR-URL: nodejs#66165
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. needs-ci PRs that need a full CI run. net Issues and PRs related to the net subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants